const express = require('express');
const path = require('path');
const cors = require('cors');
const app = express();
const PORT = 7188;

// 设置CORS策略
app.use(cors({
    origin: '*', // 允许来自这个源的请求
    credentials: true // 允许发送Cookies
}));

// 设置静态资源目录
app.use(express.static(path.join(__dirname, 'public')));

// 处理根路由请求
app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

// 启动服务器
app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
});